package com.tzxs.pay.main.gt;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.igexin.sdk.GTIntentService;
import com.igexin.sdk.PushManager;
import com.igexin.sdk.message.GTCmdMessage;
import com.igexin.sdk.message.GTNotificationMessage;
import com.igexin.sdk.message.GTTransmitMessage;
import com.tzxs.pay.main.gt.broadcast.GtReceiver;
import com.tzxs.pay.util.ISharedPreference;

//个性推送
public class IntentService extends GTIntentService {
    @Override
    public void onReceiveServicePid(Context context, int i) {
        Log.d(TAG, "onReceiveServicePid -> " + i);
    }

    @Override
    public void onReceiveClientId(Context context, String s) {

        Log.d("IntentService", "onReceiveClientId: 个性推送的id:" + s);
        //将cid保存到本地
        ISharedPreference.getInstance(getApplication()).saveCid(s);
    }


    @Override
    public void onReceiveMessageData(Context context, GTTransmitMessage gtTransmitMessage) {

        Log.d(TAG, "onReceiveMessageData: 推送消息的messageId" + gtTransmitMessage.getMessageId());
    }

    @Override
    public void onReceiveOnlineState(Context context, boolean b) {

    }

    @Override
    public void onReceiveCommandResult(Context context, GTCmdMessage gtCmdMessage) {

    }

    @Override
    public void onNotificationMessageArrived(Context context, GTNotificationMessage gtNotificationMessage) {
        Log.d(TAG, "onNotificationMessageArrived: 推送的title：" + gtNotificationMessage.getTitle());
        Log.d(TAG, "onNotificationMessageArrived: 推送的内容：" + gtNotificationMessage.getContent());

        Intent intent = new Intent();
        intent.setAction(GtReceiver.action);
        intent.putExtra("content", gtNotificationMessage.getContent());
        sendBroadcast(intent);
    }

    @Override
    public void onNotificationMessageClicked(Context context, GTNotificationMessage gtNotificationMessage) {

    }


}
